import os
import re

def get_current_file_path() -> str:
    """
    获取当前工作路径
    :return:str
    """
    return os.getcwd()

def get_config_path(current, data_config) -> dict:
    """
    把yaml 配置文件里的路径拼成绝对路径
    :param current:
    :param config:
    :return:
    """
    data = dict()
    for key, value in data_config.items():
        data[key] = os.path.join(current, value)

    return data

def paste_path(current_path, file_path) -> str:
    """
    拼接路径
    :param current_path:
    :param file_path:
    :return:
    """
    end = os.path.join(current_path, file_path)

    return end

def get_apk_single_name(res) -> str:
    """
    获取apk 名称
    :param apk_path:
    def extract_apk_filename(filepath):
    """
    apk_path = res['Apk']
    pattern = r"[^\\/]+\.apk$"
    match = re.search(pattern, apk_path)

    if not match:
        return res
    else:
        res['Apk'] = match.group(0)
        return res

def get_apk_multi_name(res):
    """
    从文件路径中提取软件名（类似"split_apk_Flipkart"部分）

    返回:
        软件名称（如"Flipkart"）
    """
    apk_path = res['Apk']

    pattern = r"[\\/]split_apk_([^\\/]+)[\\/]"
    match = re.search(pattern, apk_path)

    if not match:
        return res
    else:
        res['Apk'] = match.group(1)
        return res